/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bda.mediatheque.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

/**
 *
 * @author samsung
 */
@Entity
@Table(name = "panier")
@NamedQueries({
    @NamedQuery(name = "Panier.findAll", query = "SELECT p FROM Panier p")})
public class Panier implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @NotNull
    @Column(name = "panierId")
    private Integer panierId;
    @Column(name = "etat")
    private Integer etat;
    @Column(name = "dateCreationPanier")
    @Temporal(TemporalType.DATE)
    private Date dateCreationPanier;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "panier")
    private List<Lignedepanier> lignedepanierList;
    @JoinColumn(name = "utilisateur", referencedColumnName = "idUtilisateur")
    @OneToOne (cascade = CascadeType.ALL,fetch=FetchType.LAZY)
    private Utilisateur utilisateur;

    public Panier() {
    }

    public Panier(Integer panierId) {
        this.panierId = panierId;
    }

    public Integer getPanierId() {
        return panierId;
    }

    public void setPanierId(Integer panierId) {
        this.panierId = panierId;
    }

    public Integer getEtat() {
        return etat;
    }

    public void setEtat(Integer etat) {
        this.etat = etat;
    }

    public Date getDateCreationPanier() {
        return dateCreationPanier;
    }

    public void setDateCreationPanier(Date dateCreationPanier) {
        this.dateCreationPanier = dateCreationPanier;
    }

    public List<Lignedepanier> getLignedepanierList() {
        return lignedepanierList;
    }

    public void setLignedepanierList(List<Lignedepanier> lignedepanierList) {
        this.lignedepanierList = lignedepanierList;
    }

    public Utilisateur getUtilisateur() {
        return utilisateur;
    }

    public void setUtilisateur(Utilisateur utilisateur) {
        this.utilisateur = utilisateur;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (panierId != null ? panierId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Panier)) {
            return false;
        }
        Panier other = (Panier) object;
        if ((this.panierId == null && other.panierId != null) || (this.panierId != null && !this.panierId.equals(other.panierId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bda.mediatheque.dao.Panier[ panierId=" + panierId + " ]";
    }
    
}
